package de.islanders.unit.player;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.List;

public class PlayerStatus {
	
	private double temperature;
	private int fatigue,
				hunger,
				thirst,
				mentalState;
	private List<PropertyChangeListener> listeners;
	private List<Disease> diseases;
	private List<Injury> injuries;
	
	public PlayerStatus(Player plr) {
		fatigue = hunger = thirst = mentalState = 0;
		temperature = 37.0d;
		listeners.add(plr.getItemHandler().getEncumbrance());
	}
	
	private void notifyListeners(String propertyName, Object oldValue, Object newValue) {
		for(PropertyChangeListener pcl : listeners) {
			pcl.propertyChange(new PropertyChangeEvent(this, propertyName, oldValue, newValue));
		}
	}
	
	/**
	 * @return the fatigue
	 */
	public int getFatigue() {
		return fatigue;
	}
	/**
	 * @param fatigue the fatigue to set
	 */
	public void setFatigue(int fatigue) {
		notifyListeners("setFatigue()", this.fatigue, this.fatigue = fatigue);
	}
	
	/**
	 * @return the temperature
	 */
	public double getTemperature() {
		return temperature;
	}
	/**
	 * @param temperature the temperature to set
	 */
	
	public void setTemperature(double temperature) {
		notifyListeners("setTemperature()", this.temperature, this.temperature = temperature);
	}
	/**
	 * @return the hunger
	 */
	public int getHunger() {
		return hunger;
	}
	/**
	 * @param hunger the hunger to set
	 */
	public void setHunger(int hunger) {
		notifyListeners("setHunger", this.hunger, this.hunger = hunger);
	}
	
	/**
	 * @return the thirst
	 */
	public int getThirst() {
		return thirst;
	}
	
	/**
	 * @param thirst the thirst to set
	 */
	public void setThirst(int thirst) {
		notifyListeners("setThirst()", this.thirst, this.thirst = thirst);
	}
	
	/**
	 * @return the mentalState
	 */
	public int getMentalState() {
		return mentalState;
	}
	/**
	 * @param mentalState the mentalState to set
	 */
	public void setMentalState(int mentalState) {
		this.mentalState = mentalState;
	}
	
	/**
	 * @return the diseases
	 */
	public List<Disease> getDiseases() {
		return diseases;
	}
	/**
	 * @param diseases the diseases to set
	 */
	public void setDiseases(List<Disease> diseases) {
		notifyListeners("setDiseases()", this.diseases, this.diseases = diseases);
	}
	
	/**
	 * @return the injuries
	 */
	public List<Injury> getInjuries() {
		return injuries;
	}
	/**
	 * @param injuries the injuries to set
	 */
	public void setInjuries(List<Injury> injuries) {
		notifyListeners("setInjuries()", this.injuries, this.injuries = injuries);
	}
}
